package edu.spec.wfl.week08.class1.book.unit4.there;

public class Student extends Person{
    private String no;
    private double scoreOfEn;
    private double scoreOfMath;
    private double scoreOfCh;
   public Student(){}
    public Student(String no,double scoreOfEn,double scoreOfMath,double scoreOfCh){
        this.no = no;
        this.scoreOfEn = scoreOfEn;
        this.scoreOfMath = scoreOfMath;
        this.scoreOfCh = scoreOfCh;
    }

    public void setNo(String no) {
        this.no = no;
    }
    public String getNo() {
        return no;
    }
    public double avr(){
        return (scoreOfEn+scoreOfMath+scoreOfCh)/3;
    }

    public double max() {
        double grade[] = new double[]{scoreOfEn, scoreOfMath, scoreOfCh};
        double Max = grade[0];
        for (int i = 1; i < grade.length; i++) {
            if (Max < grade[i])
                Max = grade[i];
        }
        return Max;
    }
    public  double min(){
        double grade[]=new double[]{scoreOfEn, scoreOfMath, scoreOfCh};
        double Min=grade[0];
        for(int i=1;i<grade.length;i++){
            if(Min>grade[i])
                Min=grade[i];
        }
        return Min;
    }

    public String toString() {
        super.toString();
        return no+scoreOfEn+scoreOfMath+scoreOfCh;
    }

    public static void main(String[] args) {
        Student s=new Student();
        s.setName("王奉琳");
        s.setAge(20);
        s.setSex('女');
        s.no="1713580022";
        s.scoreOfEn=90;
        s.scoreOfMath=99;
        s.scoreOfCh=95;
        System.out.println("学号:"+s.no+"\t"+"姓名:"+s.getName()+"\t"+"性别:"+s.getSex());
        System.out.println("最大值为："+s.max()+"最小值为："+s.min()+"平均分为："+s.avr());
    }
}
